#include <bits/stdc++.h>
using namespace std;
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
using ll = long long;
ll a[100010];
map<ll, ll> mp;
void solve()
{
    mp[0] = 1;
    ll n,k;
    cin >> n>> k;
    for(ll i=1;i<=n;i++)
    {
        cin >> a[i];
        a[i] = a[i]+a[i - 1];
        mp[a[i] % k]++;
    }
    ll ans = 0;
    for(ll i=0;i<k;i++)
    {
        ans += max(0ll, (mp[i] * (mp[i] - 1)) / 2);
    }
    cout << ans;
}
int main()
{
    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
   return 0;
}
